<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:p="http://primefaces.org/ui">
	
<h:head>
	<h:outputStylesheet library="css" name="main.css" />
</h:head>

<h:body>
<ui:composition template="/template/default.xhtml">
	<ui:define name="no_form">
	<h:outputScript name="locales.js" library="js"/> 
	<h:form id="form">
	
		<p:panel id="panel" header="#{msgs.msgPaneBuscarLaudo}">
		
		<h:panelGrid columns="2">
		
		<h:outputLabel for="dataInicial" value="#{msgs.dataInicial}" />
		<p:calendar id="dataInicial"  
			showOn="button" 
			pattern="dd/MM/yyyy" 
			locale="pt_BR" 
			required="false"
			value="#{laudoMB.dataInicial}"
			/>
		
		
		<h:outputLabel for="dataFinal" value="#{msgs.dataFinal}" />
		<p:calendar id="dataFinal"  
			showOn="button" 
			pattern="dd/MM/yyyy" 
			locale="pt_BR" 
			required="false"
			value="#{laudoMB.dataFinal}"
			/>
		
		
		<p:outputLabel value="Paciente:" for="paciente" />  
        <p:autoComplete 
            	id="paciente" 
            	dropdown="true"
            	forceSelection="true"
                completeMethod="#{relatoriosMB.pacienteAutocomplete}"
                maxResults="10"
                minQueryLength="3"
                size="120"
                var="paciente"
                itemLabel="#{paciente.autocomplete}"
                itemValue="#{paciente}"
                required="false"
                value="#{laudoMB.pacienteBuscaLaudo}"
         />  
			
			<h:outputLabel for="texto" value="#{msgs.textoModeloLaudo}" />
			<p:inputText id="texto" value="#{laudoMB.textoBuscaLaudo}" 
				required="false" maxlength="40" size="40"
			/>
			
			
		</h:panelGrid>
		
		<h:panelGrid columns="2">
						<p:commandButton action="#{laudoMB.fazBusca()}" value="#{msgs.pesquisar}" icon="ui-icon-search" update="form"/>
		</h:panelGrid>
		
		</p:panel>
		
		<p:outputPanel id="laudos">
					<p:dataTable id="modeloLaudoTable" var="laudo" value="#{laudoMB.laudoLazyDataModel}" paginator="true" rows="10"
                 		paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                 		rowsPerPageTemplate="5,10,15,25,50" lazy="true" selectionMode="single" selection="#{laudoMB.laudoSelecionado}">

						<p:column>
							<f:facet name="header">
								<h:outputText value="#{msgs.data}" />
							</f:facet>
							<h:outputText value="#{laudo.dataStr}" />
						</p:column>
						
						<p:column>
							<f:facet name="header">
								<h:outputText value="#{msgs.paciente}" />
							</f:facet>
							<h:outputText value="#{laudo.paciente.nome}" />
						</p:column>
						
						<p:column>
							<f:facet name="header">
								<h:outputText value="#{msgs.textoModeloLaudo}" />
							</f:facet>
							<h:outputText value="#{laudo.textoDataTable}" escape="false"/>
						</p:column>

						<f:facet name="footer">
							<p:commandButton action="#{laudoMB.laudo()}" value="#{msgs.novoLaudo}" icon="ui-icon-plus" ajax="false"/>  
            				<p:commandButton id="visualizar" value="#{msgs.visualizar}" icon="ui-icon-search" action="#{laudoMB.visualizarLaudo()}" ajax="false"/>
        				</f:facet> 

					</p:dataTable>
		</p:outputPanel>
		
		<h:panelGrid columns="2">
			<h:commandButton action="#{prescricaoMB.listPacientes()}" value="#{msgs.voltar}" immediate="true"/>
		</h:panelGrid>
		
	</h:form>
	</ui:define>
</ui:composition>
	
</h:body>
</html>